import * as THREE from 'three';
import { lon2xyz }  from './math.js';

const model = new THREE.Group();
var R =100
const geometry = new THREE.SphereGeometry( R, 32, 16 );
const texture = new THREE.TextureLoader().load( '/earth2.jpg' );
const material = new THREE.MeshBasicMaterial( { map:texture } );
const sphere = new THREE.Mesh( geometry, material );
const globule =  helpSphere(5,113.5,34.5)
model.add( sphere,globule );

function helpSphere(r,longitude,latitude){
    const helpGeo = new THREE.SphereGeometry( r, 32, 16 );
    const helpMat = new THREE.MeshBasicMaterial( { color:0xff0000 } );
    const helpSphere = new THREE.Mesh( helpGeo, helpMat );
    const obj = lon2xyz(R,longitude,latitude)
    helpSphere.position.set(obj.x,obj.y,obj.z)
    return helpSphere;

  }
export {model};